package week03;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

abstract class Shape{
	final double PI=3.14;
	public abstract double getPerimeter();
	public abstract double getArea();
	
	public double sumAllPerimeter(int fx,int yx,Rectangle[] rectangle,Circle[] circle){
		double all=0;
		for (int i = 0; i < fx; i++) {
			all+=rectangle[i].getPerimeter();
		}
		for (int i = 0; i < yx; i++) {
			all+=circle[i].getPerimeter();
		}
		return all;
	}
	public double sumAllArea(int fx,int yx,Rectangle[] rectangle,Circle[] circle){
		double all=0;
		for (int i = 0; i < fx; i++) {
			all+=rectangle[i].getArea();
		}
		for (int i = 0; i < yx; i++) {
			all+=circle[i].getArea();
		}
		return all;
	}
}
class Rectangle extends Shape{
	
	private int width;
	private int length;
	
	public Rectangle(int width, int length) {
		super();
		this.width = width;
		this.length = length;
	}
	public Rectangle(){
		
	}
	public double getPerimeter(){
		return (width+length)*2;
	}
	public double getArea(){
		return width*length;
	}
	@Override
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}
}
class Circle extends Shape{
	private int radius;
	public Circle(int radius){
		super();
		this.radius=radius;
	}
	public Circle(){
		
	}
	public double getPerimeter(){
		return 2*PI*radius;
	}
	public double getArea(){
		return PI*radius*radius;
	}
	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}
	
}


	
public class ddk2 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in 

);
		ArrayList c=new ArrayList();
		ArrayList b=new ArrayList();
		ArrayList j=new ArrayList();
		ArrayList h=new ArrayList();
		Rectangle text=new Rectangle();
		Circle text1=new Circle();
		while(true){
			int fx=0;
			int yx=0;
			int one=0;
			int two=0;
			int x=Integer.parseInt(sc.nextLine());
			for (int i = 0; i < x; i++) {
				String z=sc.nextLine();
				if(z.equals("rect")){
					c.add(sc.nextLine());
					fx++;
					j.add(0);
				}
				else if(z.equals("cir")){
					b.add(sc.nextLine());
					yx++;
					j.add(1);
				}
			}
			Rectangle[] rectangle=new Rectangle[fx];
			Circle[] circle=new Circle[yx];
			for (int i = 0; i < fx; i++) {
				String n=String.valueOf(c.get(i));
				String[] str= n.split(" ");
				int m=Integer.parseInt(str[0]);
				int l=Integer.parseInt(str[1]);
				rectangle[i]=new Rectangle(m,l);
			}
			for (int i = 0; i < yx; i++) {
				String n=String.valueOf(b.get(i));
				int k=Integer.parseInt(n);
				circle[i]=new Circle(k);
			}
			
			System.out.println(rectangle[0].sumAllPerimeter(fx,yx,rectangle,circle));
			System.out.println(rectangle[0].sumAllArea(fx,yx,rectangle,circle));
			int num=0;
			int num1=0;
			for (int i = 0; i < j.size(); i++) {
				if(j.get(i).equals(0)){
					h.add(rectangle[num].toString());
					num++;
				}
				else{
					h.add(circle[num1].toString());
					num1++;
				}
			}
			System.out.println(h.toString());
			for (int i = 0; i < x; i++) {
				if(j.get(i).equals(0)){
					System.out.println(text.getClass()+","+text.getClass().getSuperclass());
				}
				else{
					System.out.println(text1.getClass()+","+text1.getClass().getSuperclass());
				}
			}
			
		}
	}


}
